package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BoxRewardTypes;
import com.ruoyi.system.service.IBoxRewardTypesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 宝箱奖励信息Controller
 * 
 * @author ruoyi
 * @date 2025-01-17
 */
@RestController
@RequestMapping("/system/types")
public class BoxRewardTypesController extends BaseController
{
    @Autowired
    private IBoxRewardTypesService boxRewardTypesService;

    /**
     * 查询宝箱奖励信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:types:list')")
    @GetMapping("/list")
    public TableDataInfo list(BoxRewardTypes boxRewardTypes)
    {
        startPage();
        List<BoxRewardTypes> list = boxRewardTypesService.selectBoxRewardTypesList(boxRewardTypes);
        return getDataTable(list);
    }

    /**
     * 导出宝箱奖励信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:types:export')")
    @Log(title = "宝箱奖励信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BoxRewardTypes boxRewardTypes)
    {
        List<BoxRewardTypes> list = boxRewardTypesService.selectBoxRewardTypesList(boxRewardTypes);
        ExcelUtil<BoxRewardTypes> util = new ExcelUtil<BoxRewardTypes>(BoxRewardTypes.class);
        util.exportExcel(response, list, "宝箱奖励信息数据");
    }

    /**
     * 获取宝箱奖励信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:types:query')")
    @GetMapping(value = "/{rewardTypeId}")
    public AjaxResult getInfo(@PathVariable("rewardTypeId") Long rewardTypeId)
    {
        return success(boxRewardTypesService.selectBoxRewardTypesByRewardTypeId(rewardTypeId));
    }

    /**
     * 新增宝箱奖励信息
     */
    @PreAuthorize("@ss.hasPermi('system:types:add')")
    @Log(title = "宝箱奖励信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BoxRewardTypes boxRewardTypes)
    {
        return toAjax(boxRewardTypesService.insertBoxRewardTypes(boxRewardTypes));
    }

    /**
     * 修改宝箱奖励信息
     */
    @PreAuthorize("@ss.hasPermi('system:types:edit')")
    @Log(title = "宝箱奖励信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BoxRewardTypes boxRewardTypes)
    {
        return toAjax(boxRewardTypesService.updateBoxRewardTypes(boxRewardTypes));
    }

    /**
     * 删除宝箱奖励信息
     */
    @PreAuthorize("@ss.hasPermi('system:types:remove')")
    @Log(title = "宝箱奖励信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{rewardTypeIds}")
    public AjaxResult remove(@PathVariable Long[] rewardTypeIds)
    {
        return toAjax(boxRewardTypesService.deleteBoxRewardTypesByRewardTypeIds(rewardTypeIds));
    }
}
